﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;
using WoChu.RfClient.Duty.IFace;

namespace WoChu.RfClient.Duty
{
    public class InventoryAdjustmentUIRule
    {
        private static InventoryAdjustmentUIRule _NewInstance = new InventoryAdjustmentUIRule();

        public static InventoryAdjustmentUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new InventoryAdjustmentUIRule();
                }

                return _NewInstance;
            }
        }

        public ResultModel<List<LocationInventoryInfo>> GetLocationInventory(string LocCode)
        {
            try
            {
                ResultModel<List<LocationInventoryInfo>> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IInventoryAdjustment>.NewInstance.InvokeWebMethod<ResultModel<List<LocationInventoryInfo>>>("GetLocationInventory", new object[] { LocCode });
                if (_result == null)
                    return new ResultModel<List<LocationInventoryInfo>>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }

        public ResultModel<bool> UpdateLocationInventory(string userID, List<LocationInventoryInfo> lstListStock)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IInventoryAdjustment>.NewInstance.InvokeWebMethod<List<LocationInventoryInfo>, ResultModel<bool>>("UpdateLocationInventory", new object[] { userID }, lstListStock);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }

        public ResultModel<bool> UpdateLocationInventoryStatus(string LocCode, string BatchCode, int status)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IInventoryAdjustment>.NewInstance.InvokeWebMethod<List<LocationInventoryInfo>, ResultModel<bool>>("UpdateLocationInventoryStatus", new object[] { LocCode, BatchCode, status },null);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }

        public ResultModel<List<LocationInventoryInfo>> GetGoodsInventoryLstByGoodCode(string GoodsCode)
        {
            try
            {
                ResultModel<List<LocationInventoryInfo>> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IInventoryAdjustment>.NewInstance.InvokeWebMethod<ResultModel<List<LocationInventoryInfo>>>("GetGoodsInventoryLstByGoodCode", new object[] { GoodsCode });
                if (_result == null)
                    return new ResultModel<List<LocationInventoryInfo>>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }
    }
}
